package org.vaadin.nf4v.ext.config.beforenav;

import org.vaadin.nf4v.core.navigation.event.NavigationState;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * Page method annotation.
 * Allows current page to listen navigation events of outgoing navigation.
 * It may be used e.g. to interrupt ongoing request and offer user to save it's state
 * before page leaving.
 * NOTE: Listener can not receive AFTER_NAVIGATION, CONTEXT_NAVIGATION or CONTEXT_ACTIVATED events, cause on this stage
 * page is replaced by new one and treated as destroyed.
 */

@Target({ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
public @interface BeforeNavigation {

    /**
     * @return navigation states to listen (empty means all events)
     */
    NavigationState[] events();
}
